package top.winshu.starter;

import org.springframework.boot.context.properties.ConfigurationProperties;
import top.winshu.common.web.upload.DatePathFormat;
import top.winshu.common.constant.ProjectCode;

/**
 * @author winshu
 * @since 2021/1/28
 **/
@ConfigurationProperties(prefix = ProjectCode.WINSHU)
public class WinshuProperties {

    private int machineId = 0;

    private String fileBasePath = "";

    private DatePathFormat fileDatePath = DatePathFormat.NONE;

    private String maxLogSize = "20MB";

    public int getMachineId() {
        return machineId;
    }

    /**
     * 设置机器编号，范围(1-1023，0为缺省值不推荐使用)
     *
     * @param machineId 机器编号
     */
    public void setMachineId(int machineId) {
        if (machineId >= 1024 || machineId <= 0) {
            throw new IllegalArgumentException("机器编号的设置范围为(1-1023)，当前值为=" + machineId);
        }
        this.machineId = machineId;
    }

    public String getFileBasePath() {
        return fileBasePath;
    }

    /**
     * 设置文件基础路径
     *
     * @param fileBasePath 基础路径
     */
    public void setFileBasePath(String fileBasePath) {
        this.fileBasePath = fileBasePath;
    }

    public String getMaxLogSize() {
        return maxLogSize;
    }

    /**
     * 设置日志文件最大尺寸
     *
     * @param maxLogSize 示例 20MB
     */
    public void setMaxLogSize(String maxLogSize) {
        this.maxLogSize = maxLogSize;
    }

    public DatePathFormat getFileDatePath() {
        return fileDatePath;
    }

    public void setFileDatePath(DatePathFormat fileDatePath) {
        this.fileDatePath = fileDatePath;
    }
}
